package com.model;

import javax.persistence.*;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import java.util.List;

/**
 * 省市区域表
 */
@Entity
@Table(name = "t_china", schema = "", catalog = "")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class TChina implements java.io.Serializable{
    private Long id;
    private String name;
    private Long pid;
    private Integer isDeleted;

    @Transient
    private List<TChina> citys;

    @Transient
    public List<TChina> getCitys () {
        return citys;
    }

    public void setCitys (List<TChina> citys) {
        this.citys = citys;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false)
    public Long getId () {
        return id;
    }

    public void setId (Long id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name", nullable = true, length = 40)
    public String getName () {
        return name;
    }

    public void setName (String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "pid", nullable = true)
    public Long getPid () {
        return pid;
    }

    public void setPid (Long pid) {
        this.pid = pid;
    }

    @Basic
    @Column(name = "is_deleted", nullable = true)
    public Integer getIsDeleted () {
        return isDeleted;
    }

    public void setIsDeleted (Integer isDeleted) {
        this.isDeleted = isDeleted;
    }

    @Override
    public boolean equals (Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TChina tChina = (TChina) o;

        if (id != tChina.id) return false;
        if (name != null ? ! name.equals(tChina.name) : tChina.name != null) return false;
        if (pid != null ? ! pid.equals(tChina.pid) : tChina.pid != null) return false;
        if (isDeleted != null ? ! isDeleted.equals(tChina.isDeleted) : tChina.isDeleted != null) return false;

        return true;
    }

    @Override
    public int hashCode () {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (pid != null ? pid.hashCode() : 0);
        result = 31 * result + (isDeleted != null ? isDeleted.hashCode() : 0);
        return result;
    }
}
